   //评论展示js
	var limit = 10;
	var currentPage = 0;
	var total;
    var j=0;
    
	$('.imgcode').click(function() {
		var url = "/captcha/captchaImage?type=math&s=" + Math.random();
		$(".imgcode").attr("src", url);
	});
    
    //提交评论
	function comment() {
		//alert($("#content").html());
		if($("#content").val()==""){
            layer.msg("说点什么吧~")
            return;
        }
		j=0;
		//alert($("#content").val());
		$.ajax({
			cache : true,
			type : "POST",
			url : "/blog/close/add",
			data : $('#form-blogcomment-add').serialize(),// 你的formid
			async : false,
			error : function(request) {
				layer.alert("Connection error");
			},
			success : function(r) {
				if (r.code == 0) {
					parent.layer.msg(r.msg);
					$('#form-blogcomment-add')[0].reset();//留言成功后重置form表单，防止重复提交数据
					//location.reload();
					$('#incomeNum').empty();
					//$('#flagLoaded').empty();
					//$('#flagLoad').empty();
					currentPage=0;
					commentList(0,contentid);
					
				} else {
					layer.msg(r.msg)
				}
			}
		});

	}
	
	
	//提交回复
	function recomment(obj) {
		//alert("contenthf"+obj);
		//alert(document.getElementById("contenthf6").value);
		if(document.getElementById("contenthf"+obj).value==""){
            layer.msg("回复点什么吧~")
            return;
        }
		j=0;
		//alert($("#content").val());
		$.ajax({
			cache : true,
			type : "POST",
			url : "/blog/close/add",
			data : $('#hf'+obj).serialize(),// 你的formid
			async : false,
			error : function(request) {
				//alert(request);
				layer.alert("Connection error");
			},
			success : function(r) {
				if (r.code == 0) {
					layer.msg(r.msg);
					$('#form-blogcomment-add')[0].reset();//留言成功后重置form表单，防止重复提交数据
					//location.reload();
					$('#incomeNum').empty();
					//$('#flagLoaded').empty();
					//$('#flagLoad').empty();
					currentPage=0;
					commentList(0,contentid);
				} else {
					layer.msg(r.msg)
				}

			}
		});

	}
	
	//游客留言
	function yksave() {
		if($("#content").val()==""){
            layer.msg("说点什么吧~")
            return;
        }
		j=0;
		$.ajax({
			cache : true,
			type : "POST",
			url : "/blog/open/savevisitor",
			data : $('#form-blogcomment-add').serialize(),// 你的formid
			async : false,
			error : function(request) {
				parent.layer.alert("Connection error");
			},
			success : function(r) {
				if (r.code == 0) {
					layer.msg(r.msg);
					$('#form-blogcomment-add')[0].reset();//留言成功后重置form表单，防止重复提交数据
					//评论成功刷新验证吗
					var url = "/captcha/captchaImage?type=math&s=" + Math.random();
					$(".imgcode").attr("src", url);
					//location.reload();
					$('#incomeNum').empty();
					//$('#flagLoaded').empty();
					//$('#flagLoad').empty();
					currentPage=0;
					commentList(0,contentid);
				} else {
					var url = "/captcha/captchaImage?type=math&s=" + Math.random();
					$(".imgcode").attr("src", url);
					layer.alert(r.msg)
				}

			}
		});

	}
	
	
	//获取验证码
	function getVerify(obj) {
	    obj.src = "/getVerify?" + Math.random();
	    console.log(obj)
	}
	//游客回复
	function ykhh(){
		//layer.msg("暂未开放!");
		//return;
		document.getElementById("isverify").style.display="block";
		document.getElementById("zhhh").style.display="block";
		document.getElementById("ykhh").style.display="none";
		document.getElementById("fs").style.display="none";
		document.getElementById("ykfs").style.display="block";
		$("#imgVerify").click();
		//$("#isverify").attr("display","block")
	}
	//账号回复
	function zhhh(){
		//layer.msg("暂未开放!");
		//return;
		document.getElementById("isverify").style.display="none";
		document.getElementById("zhhh").style.display="none";
		document.getElementById("ykhh").style.display="block";
		document.getElementById("fs").style.display="block";
		document.getElementById("ykfs").style.display="none";
		//$("#isverify").attr("display","block")
	}
    
	//加载留言列表
	function commentList(obj,contentid) {
		$.ajax({
				url : '/blog/open/listcomment?pageSize='+ pagesize +'&pageNum=' + obj + '&objColumn=' + contentid,
				method : 'get',
				dataType : 'json',
				success : function(data) {
					var rows = data.rows;
					total = data.total;
					var htmlText = "";
					if(total!=0){
						for (i = 0; i < rows.length; i++,j++) {
							if(rows[i].type==1){
								htmlText += '<div  id="ly'+rows[i].id+'" class="post-preview">';
								htmlText += '<br>';
								htmlText += '<span><a style="text-decoration:none;" value="' + rows[i].userId + '" onclick="openuser(this)"><img alt="image"  class="img-circle" style="cursor:pointer;" height="35" width="35" src="'+rows[i].avatar+'"/><span class="hand">'+rows[i].userName+'</span></a><span class="pull-right">'+(j+1)+'楼</span></span>';
								htmlText += '<a>';
								htmlText += '<br><span class="fontsize25">';
								htmlText += rows[i].content;
								htmlText += '</span>';
								htmlText += '</a>';
								
								htmlText += '<p class="post-meta"><span>评论时间:'
									+ ' &nbsp;&nbsp; '
									+ rows[i].createDate + '</span> &nbsp;&nbsp;<a class="pull-right" onclick="huifu('+j+')"><span>回复</span></a> </p>';	
								htmlText += '<form class="form-horizontal m-t" style="display:none" id="hf'+j+'">';
								htmlText += '<div class="form-group">';
								//htmlText += '<label for="name">我有话说：</label>';
								htmlText += '<textarea id="contenthf'+j+'" name="content" class="form-control" require="" rows="3" placeholder="请输入回复内容" ></textarea>';
								htmlText += '</div>';
								htmlText += '<div class="form-group hidden">';
								htmlText += '<input id="pid" name="pid" class="form-control" type="text" value="'+rows[i].userId+'">';
								htmlText += '<input id="contentId" name="contentId" class="form-control" type="text" value="'+contentid+'">';
								htmlText += '<input id="type" name="type" class="form-control" type="text" value="2">';
								htmlText += '<input id="plnrid" name="plnrid" class="form-control" type="text" value="'+rows[i].commentId+'">';
								htmlText += '</div>';
								htmlText += '<div style="text-align:right">';
								htmlText += '<a class="btn btn-secondary float-right" id="fs" href="javascript:void(0)" onclick="recomment('+j+')"><span>发送 &rarr;</span></a>';
								htmlText += '</div>';
								htmlText += '</form>';
								htmlText += '</div>';
								htmlText += '<hr>';
							}else{
								htmlText += '<div  id="ly'+rows[i].id+'" class="post-preview">';
								htmlText += '<br>';
								htmlText += '<span><a style="text-decoration:none;" value="' + rows[i].userId + '" onclick="openuser(this)"><img alt="image" style="cursor:pointer;" class="img-circle" height="35" width="35" src="'+rows[i].avatar+'"/><span>'+rows[i].userName+'</span></a>&nbsp;&nbsp;回复：<span class="pull-right">'+(j+1)+'楼</span></span>';
								htmlText += '<br>&nbsp;&nbsp@<a value="' + rows[i].pid + '" onclick="openuser(this)" style="font-size:15px;text-decoration:none;"><img alt="image" style="cursor:pointer;" class="img-circle" height="20" width="20" style="cursor:pointer;" src="'+rows[i].pavatar+'"/><span>'+rows[i].puserName+'</span></a>：<span style="color:red;font-size:15px;">&nbsp;&nbsp;“'+rows[i].hfpl+'”&nbsp;&nbsp;</span>';
								//htmlText += '<br><br>@<a href="/blog/pm/' + rows[i].pid + '">'+rows[i].hfname+'</a><span>：“&nbsp;&nbsp;'+rows[i].hfpl+'&nbsp;&nbsp;”</span>';
								htmlText += '<br><a>';
								htmlText += '<span class="fontsize25">';
								htmlText += rows[i].content;
								htmlText += '</span>';
								htmlText += '</a>';
								
								htmlText += '<p class="post-meta"><span>评论时间:'
									+ ' &nbsp;&nbsp; '
									+ rows[i].createDate + '</span> &nbsp;&nbsp;<a class="pull-right" onclick="huifu('+j+')"><span>回复</span></a> </p>';	
								htmlText += '<form class="form-horizontal m-t" style="display:none" id="hf'+j+'">';
								htmlText += '<div class="form-group">';
								//htmlText += '<label for="name">我有话说：</label>';
								htmlText += '<textarea id="contenthf'+j+'" name="content" class="form-control" require="" rows="3" placeholder="请输入回复内容" ></textarea>';
								htmlText += '</div>';
								htmlText += '<div class="form-group hidden">';
								htmlText += '<input id="pid" name="pid" class="form-control" type="text" value="'+rows[i].userId+'">';
								htmlText += '<input id="contentId" name="contentId" class="form-control" type="text" value="'+contentid+'">';
								htmlText += '<input id="type" name="type" class="form-control" type="text" value="2">';
								htmlText += '<input id="plnrid" name="plnrid" class="form-control" type="text" value="'+rows[i].commentId+'">';
								htmlText += '</div>';
								//htmlText += '<input id="plnrid" name="plnrid" class="form-control" type="text" value="'+rows[i].id+'">';
								htmlText += '<div style="text-align:right">';
								htmlText += '<a class="btn btn-secondary float-right" id="fs" href="javascript:void(0)" onclick="recomment('+j+')"><span>发送 &rarr;</span></a>';
								htmlText += '</div>';
								htmlText += '</form>';
								htmlText += '</div>';
								htmlText += '<hr>';
							}
						}
						$("#incomeNum").append(htmlText);
						document.getElementById("flagLoad").style.display = "block";
						document.getElementById("flagLoaded").style.display = "none";
						currentPage++;
						//alert(total);
						//alert(currentPage * limit);
						if (total <= currentPage * limit) {
							document.getElementById("flagLoaded").style.display = "block";
							document.getElementById("flagLoad").style.display = "none";
						}
					}else{
						htmlText += '<div class="post-preview text-center">';
						htmlText += '<p>评论区空空如也！好生凄凉啊！</p>';
						htmlText += '<img class="xz" src="/img/logo/honey-b.png" alt="">';
						htmlText += '</div>';
						$("#incomeNum").append(htmlText);
						document.getElementById("flagLoaded").style.display = "none";
						document.getElementById("flagLoad").style.display = "none";
					}
				}
			});
	}
	
	//打开回复框
	function huifu(obj){
		document.getElementById("hf"+obj).style.display="block";
		//$(obj).show();
	}
	 
